const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  publicPath: './',
  // 不转译所有依赖，避免对超大库(opencv.js等)进行 Babel 处理导致内存溢出
  transpileDependencies: false,
  // 将 OpenCV 作为外部依赖，从全局变量 `cv` 获取，避免打包进构建
  configureWebpack: {
    externals: {
      'opencv.js': 'cv',
      '@techstark/opencv-js': 'cv',
    },
  },
  devServer: {
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:9999',
        changeOrigin: true,
        ws: false,
        pathRewrite: { '^/api': '' },
      },
    },
  },
  chainWebpack: config => {
    config.plugin('html').tap(args => {
      args[0].title = '声声不息'
      return args
    })
  }
})